package com.dd.service;

import com.dd.model.OtherDataStatics;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class OtherDataStaticsService {
    private static final String JSON_PATH = "src/main/resources/other_data_statics.json";
    private Gson gson = new Gson();

    public List<OtherDataStatics> getOtherDataStatics() {
        try (FileReader reader = new FileReader(JSON_PATH)) {
            Type listType = new TypeToken<ArrayList<OtherDataStatics>>(){}.getType();
            List<OtherDataStatics> list = gson.fromJson(reader, listType);
            return list != null ? list : new ArrayList<>();
        } catch (IOException e) {
            System.err.println("Error loading other data statics: " + e.getMessage());
            return new ArrayList<>();
        }
    }
} 